package testClient;

import java.io.IOException;
import testClient.customerClient.CustomerClient;
import testClient.testScenarios.*;

//main program to demonstrate functionality of box office servers and customer clients

public class Main {
    public static void main(String[] args) {
	//test scenarios
	try{ 
            testCase1(args);
            testCase2(args);
            testCase3(args);
	}
	catch (Exception e) {
	    System.out.println(e.getMessage());
	}
    }

    //valid exchange operation on same box office
    public static void testCase9(String[] args) throws IOException {
        Customer10 customer = new Customer10(args, "TOR000", "TOR001");
        customer.start();
    }
    //valid exchange operation on different box offices
    public static void testCase10(String[] args) throws IOException {
        Customer10 customer = new Customer10(args, "TOR002", "MTL000");
        customer.start();
    }
    //desired show sold out
    public static void testCase11(String[] args) throws IOException {
        Customer10 customer = new Customer10(args, "TOR002", "MTL911");
        customer.start();
    }
    //try to exchange tickets that you haven't reserved
    public static void testCase12(String[] args) throws IOException {
        Customer11 customer = new Customer11(args, "TOR002", "MTL000");
        customer.start();
    }
    //two clients exchanging for same show at once
    public static void testCase13(String[] args) throws IOException,InterruptedException {
        Customer12 customer1 = new Customer12(args, "TOR474", "MTL010");
        Customer12B customer2 = new Customer12B(args, "TOR474", "MTL010");
        customer1.start();
        customer2.start();
        customer1.join();
        customer2.join();
    }
    public static void testCase15(String[] args) throws IOException,InterruptedException {
        Customer12 customer1 = new Customer12(args, "TOR474", "MTL010");
        Customer12B customer2 = new Customer12B(args, "MTL010", "TOR474");
        customer1.start();
        customer2.start();
        customer1.join();
        customer2.join();
    }
    //
    //try to reserve more tickets than you're cancelling
    public static void testCase14(String[] args) throws IOException {
        Customer13 customer = new Customer13(args, "TOR000", "MTL000");
        customer.start();
    }
    
    //test check() method for single client
    public static void testCase1(String[] args) throws IOException {
	Customer1 customer = new Customer1(args, "MTL000");
	customer.start();
    }

    //test reserve() method for single client
    public static void testCase2(String[] args) throws IOException {
	Customer2 customer = new Customer2(args, "TOR003");
	customer.start();
    }

    //test cancel() method for single client
    public static void testCase3(String[] args) throws IOException {
	Customer3 customer = new Customer3(args, "TOR003");
	customer.start();
    }

    //test reserve() method for single client when show is sold out
    public static void testCase4(String[] args) throws IOException {
	Customer4 customer = new Customer4(args, "MTL911");
	customer.start();
    }

    //test trying to cancel() more tickets than have been reserved 
    public static void testCase5(String[] args) throws IOException {
	Customer5 customer = new Customer5(args, "VAN000");
	customer.start();
    }

    //several clients reserve()-ing tickets for the same show at once
    public static void testCase6(String[] args) throws IOException,  InterruptedException{
	Customer9A customerA = new Customer9A(args, "TOR002");
	Customer9B customerB = new Customer9B(args, "TOR002");
	customerA.start();
	customerB.start();
	customerA.join();
	customerB.join();
    }

    //several clients cancel()-ing tickets for the same show at once
    public static void testCase7(String[] args) throws IOException,  InterruptedException{
	Customer7A customerA = new Customer7A(args, "TOR002");
	Customer7B customerB = new Customer7B(args, "TOR002");
	customerA.start();
	customerB.start();
	customerA.join();
	customerB.join();
    }
    
    //several clients reserving()ing and cancel()-ing tickets for the same show at once
    public static void testCase8(String[] args) throws IOException,  InterruptedException{
	Customer9A customerA = new Customer9A(args, "TOR002");
	Customer7B customerB = new Customer7B(args, "TOR002");
	customerA.start();
	customerB.start();
	customerA.join();
	customerB.join();
    }
}
